<?php

/**
 * This is the model class for table "{{shops}}".
 *
 * The followings are the available columns in table '{{shops}}':
 * @property integer $shop_id
 * @property string $shop_name
 * @property string $shop_author
 * @property string $platform_type
 * @property string $sumary
 * @property string $img
 * @property integer $follow_count
 * @property string $ctime
 * @property string $mtime
 * @property string $status
 */
class Shops extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Shops the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{shops}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('shop_name, shop_author, sumary, img, ctime', 'required'),
			array('follow_count', 'numerical', 'integerOnly'=>true),
			array('shop_name', 'length', 'max'=>60),
			array('shop_author', 'length', 'max'=>30),
			array('platform_type, status', 'length', 'max'=>7),
			array('img', 'length', 'max'=>255),
			array('mtime', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('shop_id, shop_name, shop_author, platform_type, sumary, img, follow_count, ctime, mtime, status', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'shop_id' => 'Shop',
			'shop_name' => 'Shop Name',
			'shop_author' => 'Shop Author',
			'platform_type' => 'Platform Type',
			'sumary' => 'Sumary',
			'img' => 'Img',
			'follow_count' => 'Follow Count',
			'ctime' => 'Ctime',
			'mtime' => 'Mtime',
			'status' => 'Status',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('shop_id',$this->shop_id);
		$criteria->compare('shop_name',$this->shop_name,true);
		$criteria->compare('shop_author',$this->shop_author,true);
		$criteria->compare('platform_type',$this->platform_type,true);
		$criteria->compare('sumary',$this->sumary,true);
		$criteria->compare('img',$this->img,true);
		$criteria->compare('follow_count',$this->follow_count);
		$criteria->compare('ctime','>='.$this->ctime,true);
		$criteria->compare('ctime','<='.$this->mtime,true);
		$criteria->compare('status',$this->status,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}